<?php

require_once(dirname(__FILE__) . '/appconf.php');

class Test extends Site {

    function setup() {
        $this->run_modes('def', 'test');
        $this->start_mode('test');
        $this->selfurl = '/test.php';
        parent::setup();
    }

    function cgiapp_prerun() {

        parent::cgiapp_prerun();
    }

    function action_test() {

        $is_array = array(9704, 9719, 9163, 8523, 6705, 5949, 5713, 5315, 546, 363, 182, 118, 99, 74, 9567, 9709, 9504, 9746, 9721, 9724, 8697, 8545, 7167, 5411, 3507, 2875, 1367, 950, 787, 786, 774, 768, 597, 545, 9262, 6603, 5714, 3552, 2537, 1370, 1155, 963, 957, 918, 795, 701, 637, 578, 486, 402, 321, 268, 265, 9271, 9250, 9162, 9157, 9095, 8901, 8699, 8552, 8547, 8544, 9723, 9635, 9260, 9254, 9201, 9144, 8974, 8592, 6608, 5609, 6610, 2613, 1154, 964, 798, 713, 404, 127);

        $limit = count($is_array);
        $param = array();
        $param['field'] = "";
        $param['where'] = "TB1.pic_num>0";
        $param['order'] = "TB1.id asc";
        $param['group'] = "TB1.num";
        $param['limit'] = $limit;
        $param['pagesize'] = "";
        $param['page'] = "";
        $param['join'] = "left join fg_product";
        $param['on'] = "TB1.num = TB2.num";
        $data = db_query_hash('fg_report', $param);

        if ($data['result']) {
            foreach ($data['result'] as $key => $value) {

                db_update('fg_product', array('pid' => $is_array[$key]), 'id=' . mysql_escape_string($value['id']));

                echo $value['id'] . "<br>";
            }
        }
    }

}

$webapp = new Test();
$webapp->run();
?>